package com.artPreter.service.impl;

import com.artPreter.pojo.ArtistSectionTemp;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.artPreter.mapper.TemplateDetailMapper;
import com.artPreter.pojo.ArtistSectionTemp;
import com.artPreter.mapper.ArtistSectionTempMapper;
import com.artPreter.pojo.TemplateDetail;
import com.artPreter.service.IArtistContentSectionService;
import com.artPreter.service.IArtistSectionTempService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 * 艺术家栏目表 服务实现类
 * </p>
 *
 * @author jarvis
 * @since 2024-11-23
 */
@Service
public class ArtistSectionTempServiceImpl extends ServiceImpl<ArtistSectionTempMapper, ArtistSectionTemp> implements IArtistSectionTempService {


    @Override
    public List<ArtistSectionTemp> getList(ArtistSectionTemp artistSectionTemp) {
        LambdaQueryWrapper<ArtistSectionTemp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(artistSectionTemp.getArtistId()!=null){
            lambdaQueryWrapper.eq(ArtistSectionTemp::getArtistId, artistSectionTemp.getArtistId());
        }
        lambdaQueryWrapper.orderByAsc(ArtistSectionTemp::getSort);
        List<ArtistSectionTemp> list = this.baseMapper.selectList(lambdaQueryWrapper);
        return list;
    }

    @Override
    public List<ArtistSectionTemp> getListBySid(Integer sid) {
        List<ArtistSectionTemp> result = new ArrayList<>();
        LambdaQueryWrapper<ArtistSectionTemp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ArtistSectionTemp::getId, sid);
        List<ArtistSectionTemp> list = this.baseMapper.selectList(lambdaQueryWrapper);
        if(list.size()>0){
            String artistId = list.get(0).getArtistId();
            lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(ArtistSectionTemp::getArtistId, artistId);
            lambdaQueryWrapper.orderByAsc(ArtistSectionTemp::getSort);
            List<ArtistSectionTemp> list2 = this.baseMapper.selectList(lambdaQueryWrapper);
            if(list2.size()>0){
                result = list2;
            }
        }

        return result;
    }
}
